package cn.net.yugu.doraemon.netty.factory.biz;

import cn.net.yugu.doraemon.netty.utils.SpringContextHolder;
import lombok.extern.slf4j.Slf4j;

/**
 * @description:
 * @author: wanghongli
 * @create: 2022-07-12 14:00:04
 */
@Slf4j
public class DefaultBizFactory implements BizFactory {
    public static final BizFactory DEFAULT_INSTANCE = new DefaultBizFactory();

    private DefaultBizFactory() {
    }

    @Override
    public Biz create(int msgCode) {
        if (log.isDebugEnabled()) {
            log.debug("get Biz from name:{}", ("biz" + String.format("%09d", msgCode)));
        }
        return (Biz) SpringContextHolder.getBean("biz" + String.format("%09d", msgCode));
    }
}
